






//
//  BaseTextView.m
//  GoldBook
//
//  Created by wmz on 2021/8/18.
//  Copyright © 2021 wmz. All rights reserved.
//

#import "BaseTextView.h"

@implementation BaseTextView

- (void)setPlaceHolder:(NSString *)placeHolder{
    _placeHolder = placeHolder;
    [self addSubview:self.placeLB];
    self.placeLB.text = placeHolder;
    if (placeHolder.length) {
        self.delegate = self;
    }
}

- (void)updateConstraints{
    [super updateConstraints];
    [self.placeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(4);
        make.top.mas_equalTo(6);
    }];
}

- (void)textViewDidChange:(UITextView *)textView{
    self.placeLB.hidden = textView.text.length;
    if (self.block) {
        self.block(textView);
    }
}

- (void)textViewDidEndEditing:(UITextView *)textView{
    if (self.endEditBlock) {
        self.endEditBlock(textView);
    }
}

- (void)setText:(NSString *)text{
    [super setText:text];
    self.placeLB.hidden = text.length;
}

- (UILabel *)placeLB{
    if (!_placeLB) {
        _placeLB = UILabel.new;
        _placeLB.add_font(self.font).add_textColor(wColor_9);
    }
    return _placeLB;
}


@end
